﻿@echo off

:: 设置日志路径
set DEL_DIR="E:\Tests"
:: 保留天数
set DAY=7
:: 删除文件夹
forfiles /p %DEL_DIR% /d -%DAY% /m "*.jpg" /c "cmd /c if @isdir==TRUE (rmdir /q /s @path)"

:: 输入日志到文件
:: %YYYY%-%MM%-%DD% %HH%:%MI%:%SS% 
set CURRENT_DATE=%date:~0,4%-%date:~5,2%-%date:~8,2%
set CURRENT_TIME=%time:~0,2%:%time:~3,2%:%time:~6,2%
echo %CURRENT_DATE% %CURRENT_TIME% -- 清理文件 >> %DEL_DIR%\my.log

exit
